#include "header.hpp"
int main()
{

    // 1.创建key
    key_t k = Getkey();
    // cout<<"k:"<<k<<endl;

    // 2.创建共享内存
    int shmid = Createshm(k, SIZE);
    // cout<<"共享内存id:"<<shmid<<endl;
    // sleep(10);

    // 3.关联共享内存
    char *shmaddr = attachshm(shmid);

    // 4.通信
    int i=0;
    while(i<50)
    {
        cout<<"client->server#"<<shmaddr<<endl;
        i++;
        sleep(1);
    }




    // 5.取消关联
    deatchshm(shmaddr);

    /*struct shmid_ds ds;
    int n=shmctl(shmid,IPC_STAT,&ds);
    if(n!=-1)
    {
        cout<<"creator pid:"<<ds.shm_cpid<<endl;
    }*/

    // 6.删除共享内存
    Delshm(shmid);
    return 0;
}